package academic.concordia.bankofquebec.managedbean;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;

import academic.concordia.bankofquebec.bean.bankAccount.IBankAccountServices;
import academic.concordia.bankofquebec.bean.session.SessionData;
import academic.concordia.bankofquebec.entity.CreditCard;

@ManagedBean(name="creditCardRequestManagedBean")
@Scope("session")
public class CreditCardRequestManagedBean implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private CreditCard creditCard;
	
	@ManagedProperty(value="#{SessionData}")
	private SessionData sessionData;
	
	@ManagedProperty(value="#{BankAccountBean}")
	private IBankAccountServices bankAccountBean;
	
	public String requestCard(){
		bankAccountBean.addAccount(creditCard, sessionData.getClient());
		return "products";
	}
	
	@PostConstruct
	public void initialize() {
		this.creditCard = new CreditCard();
	}

	public CreditCard getCreditCard() {
		return creditCard;
	}

	public void setCreditCard(CreditCard creditCard) {
		this.creditCard = creditCard;
	}

	public IBankAccountServices getBankAccountBean() {
		return bankAccountBean;
	}

	public void setBankAccountBean(IBankAccountServices bankAccountBean) {
		this.bankAccountBean = bankAccountBean;
	}

	public SessionData getSessionData() {
		return sessionData;
	}

	public void setSessionData(SessionData sessionData) {
		this.sessionData = sessionData;
	}
	
}
